package com.ailight.smart.ai.assembler;

import com.ailight.smart.ai.command.AiCommand;
import com.ailight.smart.ai.command.LightModelCommand;
import com.ailight.smart.ai.domain.dto.deepseek.DeepSeekParamDTO;
import com.ailight.smart.ai.enums.AiModelEnum;
import com.ailight.smart.ai.enums.OperationTypeEnums;
import org.springframework.http.MediaType;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: 朱海鹏
 * @Package: com.ailight.smart.ai.assembler
 * @Project: ai-light
 * @date: 2025/3/19 12:59
 * @description :
 */
public class AiModelAssembler {
    public static DeepSeekParamDTO buldeDpParam(AiCommand command, AiModelEnum modelEnum) {
        DeepSeekParamDTO.DpParam dpParamSystem = new DeepSeekParamDTO.DpParam();
        dpParamSystem.setRole("system");
        dpParamSystem.setContent("你是一位Java开发工程师");
        DeepSeekParamDTO.DpParam dpParamUser = new DeepSeekParamDTO.DpParam();
        dpParamUser.setRole("user");
        dpParamUser.setContent(command.getQuestion());
        List<DeepSeekParamDTO.DpParam> params = Arrays.asList(dpParamSystem, dpParamUser);
        return new DeepSeekParamDTO(modelEnum.getModelName(),
                params, command.getStream());
    }

    public static Map<String, String> buideDpHeardMap(String key, boolean stream) {
        Map<String, String> heardMap = new HashMap<>();
        heardMap.put("Authorization", "Bearer " + key);
        if (stream) {
            heardMap.put("Accept", MediaType.TEXT_EVENT_STREAM_VALUE);
        }
        heardMap.put("Content-Type", MediaType.APPLICATION_JSON_VALUE);

        return heardMap;
    }

    public static LightModelCommand getLightModelCommand(OperationTypeEnums enums) {
        return new LightModelCommand(enums.getModelEnums().getModel(), enums.getGearType());
    }
}
